import request from '@/utils/request'
const clientId = process.env.VUE_APP_CLIENT_ID
const baseUrl = process.env.VUE_APP_TMS_IAM_HOST

export function getCsrfToken() {
  const data = {
    clientId: clientId
  }
  return request({ url: `${baseUrl}/api/v1/auth/csrf`, method: 'post', data })
}

export async function login(data) {
  return request({
    url: `${baseUrl}/api/v1/auth/token`,
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: `${baseUrl}/api/v1/auth/user-info`,
    method: 'post'

  })
}

export function logout() {
  return request({
    url: `${baseUrl}/api/v1/auth/token/revoke`,
    method: 'post'
  })
}

export async function getAuthCode(data) {
  // 正式链接==>/api/v1/auth/sms-auth-code
  data.clientId = clientId
  return request({
    url: `${baseUrl}/api/v1/auth/sms-auth-code`,
    method: 'post',
    data
  })
}
